/**
 * Created by JasonChou on 16/6/30.
 */
import Vue from 'vue';
import {dateFormat, timeFormat} from './dateFormat';

Vue.filter('publishTime', function (date) {
  date = new Date(date).getTime();
  var now = Date.now();

  var diff = now - date; //毫秒

  var _10Mins = 10 * 60 * 1000;

  if (diff <= _10Mins) {
    return '刚刚';
  }


  var _60Mins = 60 * 60 * 1000;

  if (diff < _60Mins) {
    return timeFormat(diff, 'm分钟前');
  }


  var _24Hours = 24 * 60 * 60 * 1000;


  if (diff < _24Hours) {
    return timeFormat(diff, 'h小时前');
  }

  return dateFormat(date, 'yy-MM-dd hh:mm');

});
